package com.letv.app.ljodfh.base;

import android.text.TextUtils;

import com.letv.app.ljodfh.beans.FocusColumn;
import com.ruihang.generalibrary.utils.ListUtils;

import java.util.ArrayList;
import java.util.List;

public class Cache {

    private static Cache instance;

    //缓存栏目数据
    private List<FocusColumn> fChannels = new ArrayList<>();

    private String currentChannelId;

    public static Cache getInstance() {
        if (null == instance) {
            instance = new Cache();
        }
        return instance;
    }
    /**
     * 主界面 不同模块间获取栏目ID （如专题）
     * @param name
     * @return
     */
    public String getCurrentColumnId(String name ){
        if (TextUtils.isEmpty(name)|| !ListUtils.isListValued(fChannels)) {
            return "";
        }else {
            for (int i = 0; i < fChannels.size(); i++) {
                if (fChannels.get(i).getChannelName().contains(name)) {
                    return ""+fChannels.get(i).getChannelId();
                }
            }
        }
        return "";
    }

    /**
     * 首页中 获取不同栏目的ID
     * @return
     */
    public String getCurrentChannelId() {
        return currentChannelId;
    }

    public void setCurrentChannelId(String currentChannelId) {
        this.currentChannelId = currentChannelId;

    }

    public List<FocusColumn> getfChannels() {
        return fChannels;
    }

    public void setfChannels(List<FocusColumn> list) {
        if(null==fChannels){
            fChannels = new ArrayList<>();
        }else{
            fChannels.clear();
        }
         fChannels.addAll(list);
    }


    private boolean isHomeToAudio = false;//是否是从精选页面进入听广播
    private boolean isHomeToBack= false;//是否是从精选页面进入看回放
    private boolean isCheckNet = false;//是否提示过4G网络播放问题

    public boolean isHomeToAudio() {
        return isHomeToAudio;
    }

    public void setHomeToAudio(boolean homeToAudio) {
        isHomeToAudio = homeToAudio;
    }

    public boolean isHomeToBack() {
        return isHomeToBack;
    }

    public void setHomeToBack(boolean homeToBack) {
        isHomeToBack = homeToBack;
    }

    public boolean isCheckNet() {
        return isCheckNet;
    }

    public void setCheckNet(boolean checkNet) {
        isCheckNet = checkNet;
    }
}
